// pages/information/information.js
var util = require('../../utils/util.js');
const date = new Date();
const years = [];
const months = [];
const days = [];
const hours = [];
const minutes = [];
//获取年
for (let i = 2018; i <= date.getFullYear() + 5; i++) {
  years.push("" + i);
}
//获取月份
for (let i = 1; i <= 12; i++) {
  if (i < 10) {
    i = "0" + i;
  }
  months.push("" + i);
}
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navbar: ['财务部', '研发部', '人力组', "综合组", "法务组"],
    //count:[0,2,3],                                  //记录不同状态记录的数量
    currentTab: '',
    icon: ['icon-caiwu', 'icon-yanfa', 'icon-human-resources', 'icon-zonghe', 'icon-fawubu'],
    iconType: ['add2'],
    list: {
      countScore: '38',
      deductionList:[
        {
          detext: '速度太慢',
          descore: '5'
        },
        {
          detext: '态度不行',
          descore: '2'
        }
      ],
      money: [
        {
          assess: '相关部门对财务部部门的满意度',
          weight: '15',
          score: '8.5'
        },
        {
          assess: '相关部门对财务部部门的满意度',
          weight: '15',
          score: '9.5'
        }
      ]
    },
    time: '2020-01',
    multiArray: [years, months],
    multiIndex: [0, 9],
    choose_year: ''
  },
  //响应点击导航栏
  navbarTap: function (e) {
    var that = this;
    this.setData({
      currentTab: e.currentTarget.dataset.id
    })
  },
  getlist() {
    var that = this,
      currentTab;
    if (that.data.currentTab == 0) {    //这里的this.data.navi是我上面data里面声明的navi     
      currentTab = 1      //上线和未上线后台给了我is_online=1或者0，我将招聘中的navi=0    
    } else if (that.data.currentTab == 1) {
      currentTab = 2
    } else if (that.data.currentTab == 2) {
      currentTab = 3
    } else if (that.data.currentTab == 3) {
      currentTab = 4
    } else {
      currentTab = 5
    }
    //wx.request({
    //url: app.globalData.url + '/rc/Position/release_list?department=' + currentTab,
    // header: {
    //   'content-type': 'application/json' // 默认值     
    // },
    //   success(res) {
    //     that.setData({
    //       list: res.data.data  //我要将list这个碗里放入后台请求的is_online=0或者1这些东西        
    //     })
    //   }
    //})
  },
  bindDateChange: function (e) {
    this.setData({
      date: e.detail.value
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //设置默认的年份
    this.setData({
      choose_year: this.data.multiArray[0][0]
    })
    this.getlist();
  },
  //获取时间日期
  bindMultiPickerChange: function (e) {
    // console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      multiIndex: e.detail.value
    })
    const index = this.data.multiIndex;
    const year = this.data.multiArray[0][index[0]];
    const month = this.data.multiArray[1][index[1]];
    this.setData({
      time: year + '-' + month
    })
  },
  //监听picker的滚动事件
  bindMultiPickerColumnChange: function (e) {
    //获取年份
    if (e.detail.column == 0) {
      let choose_year = this.data.multiArray[e.detail.column][e.detail.value];
      console.log(choose_year);
      this.setData({
        choose_year
      })
    }
    if (e.detail.column == 1) {
      let num = parseInt(this.data.multiArray[e.detail.column][e.detail.value]);
      let temp = [];
    }
    var data = {
      multiArray: this.data.multiArray,
      multiIndex: this.data.multiIndex
    };
    data.multiIndex[e.detail.column] = e.detail.value;
    this.setData(data);
  }

})